<?php
/**
 * autoload.class.php 自动加载类
 *
 * 只自动加载lib下的业务类、common下的常用类以及table层的类。
 *
 */
class Autoload {
	// 自动读取的路径
	private static $config = array();

	public function __construct() {
		self::$config['lib'] = $GLOBALS['LIB_PATH'];
		self::$config['common'] = $GLOBALS['LIB_COMMON_PATH'];
	}
	// 路径加载初始化
	protected static function initialize() {
		var_dump($GLOBALS);
		foreach (self::$config as $path) {
			set_include_path($path.PATH_SEPARATOR.get_include_path());
		}
	}
	/**
	 * Autoload::autoload()
	 * @param  [type] $classname [description]
	 * @return 
	 */
	public static function loading($classname) {
        self::initialize();

        $classname = strtolower($classname);

		$filename = $classname.".class.php";

        if(file_exists($filename) && is_file($filename)) {
        	require_once($filename);
            return;
        }
    }
}